Skip to content

feat(nautobotop): Add VLAN, Prefix, RIR, Role, and Tenancy sync support#1893

Merged
abhimanyu003 merged 5 commits intomainfrom
nautobotOpVlan
Apr 1, 2026
Merged

feat(nautobotop): Add VLAN, Prefix, RIR, Role, and Tenancy sync support#1893
abhimanyu003 merged 5 commits intomainfrom
nautobotOpVlan

Conversation

@abhimanyu003
Copy link
Copy Markdown
Contributor

Description:

This PR adds sync support for several new resource types.

  • Added imroc/req HTTP-Client with built-in retry and backoff to handle any API failure
  • Cache pre-loading was extended to cover all new resource types.

New syncs added:

  • VLAN
  • Prefix
  • RIR (Regional Internet Registry)
  • Role
  • Tenant Group
  • Tenant
  • VRF (lookup only)
  • Tag (lookup only)

The Nautobot API client was updated to use

Let me check if there are existing sample files for the other resource types too.

Now let me also check the models for VRF and Tag to show their structure:

Here are the sample YAMLs for all resource types:

VLAN:

- name: mgmt-vlan-100
  vid: 100
  status: Active
  role: Guest
  description: Management VLAN
  locations:
    - iad3
  vlan_group: management-vlans
  tenant_group: infrastructure
  tenant: network-ops
  dynamic_groups:
    - all-switches
  tags:
    - production
    - managed

Prefix:

- prefix: "10.0.0.0/8"
  namespace: Global
  type: container
  status: Active
  role: Infrastructure
  rir: "RFC 1918"
  date_allocated: "2024-01-15 10:30:00"
  description: Private address space
  vrfs:
    - management-vrf
  locations:
    - iad3
    - dfw1
  vlan_group: management-vlans
  vlan: mgmt-vlan-100
  tenant_group: infrastructure
  tenant: network-ops
  tags:
    - production

RIR:

- name: "RFC 1918"
  is_private: true
  description: Private IPv4 address space
- name: ARIN
  is_private: false
  description: American Registry for Internet Numbers

Role:

- name: Management
  color: "0000ff"
  description: Management network role
  weight: 1000
  content_types:
    - "ipam.vlan"
    - "ipam.prefix"

Tenant Group:

- name: infrastructure
  description: Infrastructure services
  parent: ""
- name: customers
  description: Customer tenants
  parent: ""

Tenant:

- name: network-ops
  description: Network Operations team
  comments: Manages all network infrastructure
  tenant_group: infrastructure
  tags:
    - production
    - managed

Testing: Its done locally and found no-error on multiple reconcile loop, as well as no error on fresh nautobot setup using helm

if authToken != "" {
config.AddDefaultHeader("Authorization", fmt.Sprintf("Token %s", authToken))
}
config.AddDefaultHeader("Authorization", fmt.Sprintf("Token %s", authToken))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always adding auth token here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that good? Is that bad?

Comment on lines +38 to +45
reqClient := req.C().
SetTimeout(30*time.Second).
SetCommonRetryCount(3).
SetCommonRetryBackoffInterval(1*time.Second, 5*time.Second).
SetCommonRetryCondition(func(resp *req.Response, err error) bool {
return err != nil || resp.StatusCode >= 500
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using req/cool http library, to handle HTTP API failure from nautobot API if any.
It will retry with back-off, it also supports long wait time.
These settings can be tweaked, but this look good default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works. If need be we can have a config file.

Copy link
Copy Markdown
Contributor

@cardoe cardoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tentatively approving but not sure of your comments.

We really need to get some documentation of the files and the data being loaded.

@abhimanyu003 abhimanyu003 added this pull request to the merge queue Apr 1, 2026
Merged via the queue into main with commit cb99ac4 Apr 1, 2026
23 checks passed
@abhimanyu003 abhimanyu003 deleted the nautobotOpVlan branch April 1, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants